﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SqlPrompt
{
	class StringUtil
	{
		public static string RemoveTrailingCrLf(string input)
		{
			input = input.Trim();

			if (input.Length > 1 && input[input.Length - 2] == '\r' && input[input.Length - 1] == '\n')
			{
				return input.Substring(0, input.Length - 3);
			}
			else if (input.Length > 0 && input[input.Length - 1] == '\n')
			{
				return input.Substring(0, input.Length - 2);
			}
			 
			return input;
		}

		public static string Plural(string input, int amount)
		{
			return Math.Abs(amount) > 1 ? input + "s" : input;
		}
	}
}
